from __future__ import absolute_import, unicode_literals
import os

import time
from celery import Celery

# 加载环境变量  修改为mall
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mall.settings')

app = Celery('meiduo')

# 加载配置项
app.config_from_object('celery_tasks.config', namespace='CELERY')

# 注册任务  注册格式: celery_tasks.包名
app.autodiscover_tasks(["celery_tasks.test", "celery_tasks.sms", "celery_tasks.email", "celery_tasks.html"])
# app.autodiscover_tasks(["celery_tasks.test"])

# 当前的目录.启动文件  在python manage.py shell 下执行
# 启动命令 : celery -A proj worker -l info
# 修改的命令 : celery -A celery_tasks.main worker -l info


# @app.task(bind=True)
# def debug_task(self):
#     for i in range(0, 15):
#         time.sleep(1)
#         print(i)
